package com.sense.cloud.coreservice.sdk.auth.utils;

import java.security.MessageDigest;

public class MD5Utils {
  /***
   * 
   * @param str.
   * @return str.
   */
  public static String md5(String str) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(str.getBytes("UTF-8"));
      byte[] bytes = md.digest();
      return StringUtils.bytes2Hex(bytes).toLowerCase();
    } catch (Exception e11) {
      throw new RuntimeException("使用MD5加密数据错误");
    }
  }
  
  /**
   * @param bs.
   * @return str.
   */
  public static String md5( byte[] bs) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(bs);
      byte[] bytes = md.digest();
      return StringUtils.bytes2Hex(bytes).toLowerCase();
    } catch ( Exception e11 ) {
      throw new RuntimeException("使用MD5加密数据错误");
    }
  }
}
